package ch07_GUI编程;

import javax.swing.*;
import java.awt.*;

public class JTextFieldDemo {
	public static void main(String[] args) {
		BaseFrame f =new BaseFrame("JTextField Demo");
		JTextField tf1 =new JTextField("文本框的初始文字");

		JTextField tf2 = new JTextField(10);
		tf2.setText("文本框二");
		tf2.setHorizontalAlignment(SwingConstants.RIGHT);
		tf2.setBackground(Color.BLUE);
		tf2.setForeground(Color.YELLOW);

		JTextField tf3 =new JTextField("文本框三",10);
		tf3.setFont(new Font("微软雅黑",Font.ITALIC,24 ));
		tf3.setHorizontalAlignment(SwingConstants.CENTER);

		f.setLayout(new FlowLayout());
		f.add(tf1);
		f.add(tf2);
		f.add(tf3);
		f.showMe();

		tf3.requestFocus();
		tf3.select(1,3);
	}
}
